package com.android.lovingpet.home.view;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;


public class HomeAdapter extends FragmentPagerAdapter {
    private CommunityFragment fragCommunity;
    private AdoptionFragment fragAdoption;
    private MineFragment fragMine;

    public HomeAdapter(FragmentManager fm) {
        super(fm);
        fragCommunity = new CommunityFragment();
        fragAdoption = new AdoptionFragment();
        fragMine = new MineFragment();
    }

    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                return fragCommunity;
            case 1:
                return fragAdoption;
            case 2:
                return fragMine;
            default:
                return fragCommunity;
        }
    }

    @Override
    public int getCount() {
        return 3;
    }

    @Override
    public int getItemPosition(Object object) {
        if (object instanceof CommunityFragment) {
            return 0;
        } else if (object instanceof AdoptionFragment) {
            return 1;
        } else {
            return 2;
        }
    }
}
